# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Lex Black <autumn-wind at web dot de>
# Contributor: Igor Nemilentsev <trezorg@gmail.com>
# Contributor: Alexander Diana <alexander@rouk.org>

pkgname=python-bcrypt
pkgver=4.0.1
pkgrel=3
pkgdesc="Modern password hashing for your software and your servers"
arch=('loong64' 'x86_64')
url="https://github.com/pyca/bcrypt"
license=('Apache')
depends=('python')
makedepends=('python-build' 'python-installer' 'python-setuptools-rust' 'python-wheel')
checkdepends=('python-pytest')
source=("$pkgname-$pkgver.tar.gz::https://github.com/pyca/bcrypt/archive/$pkgver.tar.gz")
sha512sums=('eb7b1d67a2d60e82e2d2e4dcb12d7808be910f9b7aefab714a22dedbffc3722182875fdcf3c8c650c0bb7c1122e9e8bead92f18bc660043b017a14957467e2a9')

build() {
  cd bcrypt-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd bcrypt-$pkgver
  python -m installer --destdir=test_dir dist/*.whl
  PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH" pytest
}

package() {
  cd bcrypt-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
}
